package com.traveling.hztraveling.controller;


import com.traveling.hztraveling.entity.po.HzCulture;
import com.traveling.hztraveling.entity.vo.CalendarEvent;
import com.traveling.hztraveling.entity.vo.Result;
import com.traveling.hztraveling.service.IHzCultureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LHD
 * @since 2025-05-29
 */
@Slf4j
@RestController
@RequestMapping("/culture")
@RequiredArgsConstructor
@Api(tags = "文化信息接口")
public class HzCultureController {

    private final IHzCultureService hzCultureService;


    @PostMapping()
    @ApiOperation("预定文化信息")
    public Result<HzCulture> addCulture(@RequestBody HzCulture hzCulture) {
        log.info("添加文化信息:{}",hzCulture);
        return hzCultureService.addCulture(hzCulture);
    }


    @GetMapping("/calendar")
    @ApiOperation("日历高亮")
    public Result<List<CalendarEvent>> calendar(@Param("year") Integer year, @Param("month") Integer month) {
        return hzCultureService.calendar(year, month);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除文化信息")
    public Result deleteCulture(@PathVariable("id") Integer id) {
        log.info("删除文化信息:{}",id);
        return hzCultureService.removeById(id) ? Result.success("删除文化信息成功") : Result.fail("删除文化信息失败");
    }

    @PostMapping("/{id}")
    @ApiOperation("修改文化信息")
    public Result updateCulture(@PathVariable("id") Integer id, @RequestBody HzCulture hzCulture) {
        log.info("修改文化信息:{}",hzCulture);
        hzCulture.setId(id);
        return hzCultureService.updateById(hzCulture) ? Result.success("修改文化信息成功") : Result.fail("修改文化信息失败");
    }

}
